home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / utilities / apurify.lha / APurify / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-11  |  573 b   |  52 lines

  1. int statica;
  2.  
  3. static test_debordement(a)
  4.     int *a;
  5.     {
  6.     int i;
  7.     ++(short*)a;
  8.     i=a[0];
  9.     }
  10.  
  11. static test(p)
  12.     int *p;
  13.     {
  14.     int z = *p;
  15.     }
  16.  
  17. static freeall(a)
  18.     int *a;
  19.     {
  20.     free(a);
  21.     }
  22.  
  23. static proc_fin()
  24.     {
  25.     int *b;
  26.     b = (long*)4;
  27.     *b = *(long*)4;
  28.     AP_Close();
  29.     }
  30.  
  31. main()
  32.     {
  33.     int *a,*b;
  34.     int c;
  35.     extern int *malloc();
  36.     AP_Init();
  37.     a=malloc(4),malloc(400),malloc(12000);
  38.     if(a)
  39.         {
  40.         if(b=malloc(15)) {a[0]=b[-10];c=b[0];free(b);}
  41.         a[1] = 0;
  42.         test(&c);b=&c;*b=0;
  43.         b = &statica;
  44.         *b = 15;
  45.         test_debordement(a);
  46.         freeall(a);
  47.         proc_fin();
  48.         test_debordement(a);
  49.         }
  50.     return 0;
  51.     }
  52.